package com.yuan.statemachine;

import com.yuan.statemachine.business.BusinessEventEnum;
import com.yuan.statemachine.business.BusinessFunctionEnum;
import com.yuan.statemachine.business.order.OrderStatusEnum;
import com.yuan.statemachine.core.EnabledStateMachine;
import com.yuan.statemachine.core.StateMachine;
import com.yuan.statemachine.core.StateResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wjwei
 */
@EnabledStateMachine
@RestController
@SpringBootApplication
public class AliStateMachineApplication {

    public static void main(String[] args) {
        SpringApplication.run(AliStateMachineApplication.class, args);
    }


    @Autowired
    private StateMachine stateMachine;

    @GetMapping("/pay")
    public StateResponseBody pay() {
        return stateMachine.doAction(BusinessFunctionEnum.ORDER, OrderStatusEnum.WAIT_PAY, BusinessEventEnum.PAY, "进行支付操作");
    }
}
